1. Technical Field
The present disclosure relates to image processing, and more particularly to a system and method for supporting clipping geometries for graphics processing unit (GPU) based ray-casting.
2. Description of Related Art
As GPUs become more powerful and programmable, implementing ray-casting directly on a GPU has become possible. For example, for volume rendering, GPU-based ray-casting has shown better performance and more flexibility in achieving various shading effects in comparison with slice-based approaches.
As compared to a GPU ray-caster, a slice-based volume renderer (also referred to as a slicer) renders a set of parallel slices, wherein each slice is defined by a proxy polygon. The vertices of the polygon specify the 3D locations of the slice in 3D space and texture coordinates of these vertices describe how volume samples are mapped onto the polygon. A GPU fragment within a slice can be considered as a single 3D point. In contract, the GPU ray-caster renders the front faces of a volume (or sub-volume) and each GPU fragment represents a ray segment with significant length. The output corresponding to a fragment is obtained by accumulating multiple volume samples along the ray. When there are clipping geometries such as cut-planes or crop-box, the fragments in a slicer are clipped individually, while the ray-segment in ray-caster could be partially clipped.
Typically, the clipping of fragments in a slicer is done outside the GPU shader either through hardware clip-planes or software clip-planes that adjust proxy polygons. For GPU ray-caster, a fragment cannot be clipped as a whole. One proposed solution moves the clip testing into the shader and applies clipping for each volume sample. This requires passing all the clip-plane information as parameters into the GPU shader program. The per-sample-cost inside the shader is incremented and affects the overall frame rate. Further, the number of clip-planes for a scene is a variable which makes it is difficult to pass plane parameters efficiently to the GPU shader.
In ray-casting, for each pixel of an image, a ray is shot from a camera passing through the center of the pixel and accumulating lighting contributions along the ray. For a polygonal model, intersections of the ray with surfaces of the model, and visible color and lighting effects at the intersection point are determined. For volumetric model, the image data is sampled at discrete positions along the ray. Each color-mapped sample plus shading effects are composited. The accumulated color is then used as the value of the pixel. When all pixel values are obtained, the image is rendered.
A traditional volume rendering method that has been widely used on graphics hardware is the slicing approach, also referred to as a slicer. Instead of accumulating sample colors along the rays, a set of parallel planes are defined. By intersecting those parallel planes with the bounding box of the volume, a set of polygons are generated. Mapping the volume as a texture onto the polygons is equivalent to extracting parallel slices from the dataset. These slices are then rendered as texture-mapped polygons in sequence. In other words, a slicer renders slice-by-slice, while a ray-caster renders ray-by-ray. In some sense, a slicer renders a volume as a set of polygons.
Both the slicer and ray-caster can be accelerated by a GPU. A typical GPU pipeline takes polygons and associated attributes, such as texture, as input. The polygons and their attributes are rasterized to generate fragments. Fragments are aligned with the pixels in the resulting image. The value of every pixel is then determined according to the fragments falling on to it.
One difference between a slicer (as well as a surface renderer) and a ray-caster is that, in a slicer, each fragment represents a point in 3D space, while in a ray-caster a fragment corresponds to a ray segment of non-ignorable length. As a result, the implementation of clipping geometries, such as cut-planes and crop-boxes is different for slicer and ray-caster. A cut-plane, also called a clip-plane, is an infinite plane that excludes all the voxels falling on one side of the plane while keep the others. A crop-box could be replaced by six volume-aligned cut-planes. For slicer, each fragment is clipped as a single element, that is, a fragment is either completely clipped or completely unclipped. Therefore, cut-planes in slicer can be achieved either through hardware clip-planes or through software cut-planes. In the latter case, the polygons are intersected with cut-planes in CPU to create clipped and smaller polygons before rendering. This however won't work for ray-caster, since each fragment includes multiple samples distributed along a ray segment. These ray samples need to be clipped individually.
One proposed solution to supporting cut-planes in ray-caster is to pass all cut-plane equations as parameters to fragment program and to modify the GPU fragment shader program, so that the clipping condition is tested before fetching each sample. If a sample is clipped, it is then excluded from contributing to the pixel color. This requires inserting additional code statements into the ray-cast fragment program, and the clipping test is applied to all samples, which may be expensive. In addition, the number of cut-planes in a scene is a variable; hence it is difficult to pass all plane equations efficiently.
Therefore, a need exists for a system and method for supporting clipping geometries for GPU-based ray-casting.